import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BookVO, BookForm, BookQuery } from '@/api/system/book/types';

/**
 * 查询图书列表
 * @param query
 * @returns {*}
 */

export const listBook = (query?: BookQuery): AxiosPromise<BookVO[]> => {
  return request({
    url: '/system/book/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询图书详细
 * @param bookId
 */
export const getBook = (bookId: string | number): AxiosPromise<BookVO> => {
  return request({
    url: '/system/book/' + bookId,
    method: 'get'
  });
};

/**
 * 新增图书
 * @param data
 */
export const addBook = (data: BookForm) => {
  return request({
    url: '/system/book',
    method: 'post',
    data: data
  });
};

/**
 * 修改图书
 * @param data
 */
export const updateBook = (data: BookForm) => {
  return request({
    url: '/system/book',
    method: 'put',
    data: data
  });
};

/**
 * 删除图书
 * @param bookId
 */
export const delBook = (bookId: string | number | Array<string | number>) => {
  return request({
    url: '/system/book/' + bookId,
    method: 'delete'
  });
};
